package com.hdc.xposeddemo;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import dalvik.system.DexClassLoader;
import dalvik.system.PathClassLoader;

public class MainActivity extends AppCompatActivity {

    private TextView tv_ad;
    private Button btn_load_ad;
    private static final String TAG = "hlib_c";


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        tv_ad = findViewById(R.id.tv_ad);
        btn_load_ad = findViewById(R.id.btn_load_ad);

        btn_load_ad.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                tv_ad.setText(getTTAd());
            }
        });


        initClassLoader();
    }

    public String getTTAd(){
        return "广告加载成功";
    }

    private void initClassLoader() {
        ClassLoader classLoader = getClassLoader();
        if (classLoader != null) {
            Log.i(TAG, "[onCreate] classLoader " + 1 + " : " + classLoader.toString());
            while (classLoader.getParent() != null) {
                classLoader = classLoader.getParent();
                Log.i(TAG, "[onCreate] classLoader " + 2 + " : " + classLoader.toString());
            }

        }

        DexClassLoader dexClassLoader = new DexClassLoader("","","",getClassLoader());

        PathClassLoader pathClassLoader = new PathClassLoader("",getClassLoader());
    }
}
